package org.springframework.prospring.ticket.web.controllers;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.prospring.ticket.service.ProvinceManager;
import org.springframework.prospring.ticket.service.ClubManager;
import org.springframework.prospring.ticket.domain.location.Province;
import org.springframework.prospring.ticket.domain.Club;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Alexis
 * Date: 30/03/2010
 * Time: 14:34:19
 * To change this template use File | Settings | File Templates.
 */
public class UpdateClubController implements Controller {

    // the Club manager service this controller uses.
    private ClubManager clubManager;


    public ClubManager getClubManager() {
        return clubManager;
    }

    public void setClubManager(ClubManager clubManager) {
        this.clubManager = clubManager;
    }

    public ModelAndView handleRequest(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        System.out.println("======================= UpdateClubController.handleRequest");
        String aMessage = "Esta por realizar una modificacion del Club!";

        Club club = clubManager.findClub(new Long(3L));

        ModelAndView modelAndView = new ModelAndView("updateClubViewName");
        modelAndView.addObject("message", aMessage);
        modelAndView.addObject("club", club);
        if (club.getFields() != null) {
            modelAndView.addObject("clubFieldsSize", club.getFields().size());            
        }

        return modelAndView;
    }
}
